#ifndef PRIORITYQEUE_ASTAR_H
#define	PRIORITYQEUE_ASTAR_H
#include <stdlib.h>
#include "CNodo.h"
#include "CasilleroA.h"


class priorityQueue_AStar {
protected:
    size_t maxsz;
    CNodo *array;
public:

    priorityQueue_AStar(size_t maxsz) : maxsz(maxsz) {
        array = new CNodo [maxsz];
    }

    virtual ~priorityQueue_AStar() {
        delete[] array;
    }

    CNodo *first() {
        for (size_t i = 0; i < maxsz; ++i) {
            if (CNodo * first = array[i].GetNext()) {
                return first;
            }
        }
        return NULL; //Cola vacia!
    }

    void insert(CNodo *n) {
        array[n->f()].link(n);
    }

    void reorder(CNodo *n, int newg, int newh) {
        n->unlink();
        n->SetG(newg);
        n->SetH(newh);
        insert(n);
    };

    void print(ostream &os) const {
        for (size_t i = 0; i < maxsz; ++i) {
            for (CNodo *v = array[i].GetNext(); v != 0; v = v->GetNext()) {
                ((CasilleroA*) (v->Casillas()))->print(cout);
            }
        }
    }
};

#endif	/* PRIORITYQEUE_ASTAR_H */

